<?php


	//extract the folderid..
	$folder = extractNumberWithKeyFromArray('folder', $_REQUEST, null);
	if (!is_null($folder)) {
		$cmsDocument->addConstraint('categorycode',$folder,'=');
	}
	
	$upUrl = $_SERVER['PHP_SELF'] . '?formNo=1&formid=160&folder='.$folder;
	
	$returnURL = $_SERVER['PHP_SELF'] . "?fileNo=1&formid=158&sorts=clear&direction=clear&pageNumber=$pageNumber&folder=$folder";
	$cancelURL = $returnURL;	
?>

<TABLE class="cms_browsetext" cellSpacing="0" cellPadding="0" width="100%" border="0">
    <TR> 
      <TH align="left" width="35">&nbsp;</TH>
      <TH align="left" >Title</TH>
      <TH width="75" align="left">Action</TH>
    </TR>

<?

	$cmsDocument->resetIterator();
	
	if ($cmsDocument->totalDocuments() > 0) {

		while ($row = $cmsDocument->nextDocument()){
			$viewUrl = "";
?>

                    <TR> 
                      <TD align="left" colSpan="3"><IMG height="7" src="/cms/images/greyline.gif" width="100%" /></TD>
                    </TR>
                    <TR> 
                      <TD class="cms_browsetext" width="35"><img width="35" height="20" src="/cms/images/icon_intranetpage.gif" /></TD>
                      <TD class="cms_browsetext" ><a href="/cms/html/index.php?fileNo=103&documentCode=<?= $row->documentcode ?>&folder=<?= $folder ?>"><?= magicClean($row->title) ?></a></TD>
                      <TD class="cms_browsetext" width="75">
                      	<a href="/cms/html/index.php?fileNo=2&documentCode=<?= $row->documentcode ?>" >Edit</a>
<? 
                      	if(deleteFormAuth($authInfo, $formDescription, $row->documentcode, $db)) {
?>
 / <a href="/cms/html/index.php?fileNo=4&documentCode=<? print($row->documentcode); ?>&returnURLEncoded=<?= urlencode($returnURL) ?>&cancelURLEncoded=<?= urlencode($cancelURL) ?>" >Delete</a>
<? 
						}
?>
						</td>
                    </TR>
<?
		}
	} else {
		print <<< EOD
<TR> 
<TD align="left" colSpan="3"><IMG height="7" src="/cms/images/greyline.gif" width="100%" /></TD>
</TR>
<TR> 
<TD class="cms_browsetext" width="35"><img src="/cms/images/spacer.gif" height="20" /></TD>
<TD class="cms_browsetext" ><I>There are no files in this folder.</I></TD>
<TD class="cms_browsetext" width="75">&nbsp;</TD>
</TR>
EOD;
	}
?>


                    <TR> 
                      <TD align="left" colSpan="3"><IMG height="7" src="/cms/images/greyline.gif" width="100%"></TD>
                    </TR>

                    <TR> 
                      <TD class="cms_browsetext" width="35"><a href="<?= $upUrl ?>"><img src="/cms/html/files/images/icon_folderup.gif" width="35" height="20" /></a></TD>
                      <TD class="cms_browsetext" ><a href="<?= $upUrl ?>"><i>.. Back to parent folder.<i></a></TD>
                      <TD class="cms_browsetext" width="75"></td>
                    </TR>
                    
                    <TR> 
                      <TD align="left" colSpan="3"><IMG height="7" src="/cms/images/greyline.gif" width="100%"></TD>
                    </TR>
                                        
                </TABLE>
<?

	$folderGid = null;
	if (!is_null($folder)) {
		$folderContent = $cmsDocument->openDocument($folder);
		if (!is_null($folderContent)) {
			$folderGid = $folderContent->gid;
		}
	}
	$addMode = CMS_ADD_QUICK_ADD_GO;
	//displayGoAdd($formDescription, $authInfo, $folderGid, array('fileNo'=>2, 'formId'=> 158, 'categorycode'=>$folder, 'returnURL' => urlencode($_SERVER['REQUEST_URI'])),$db);
	$addUrlDict = array(
			'fileNo'=>2,
			'formId'=> 158,
			'categorycode'=>$folder,
			'returnURL' =>  $returnURL ,//return url in this is encoded when the input is written out.
			'gid' => $folderGid
	);
?>